<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">
    <ui:define name="content">
        <h:form>
        <p:panel id="panel" header="Add New Meal">
            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>
            <p:messages/>

            <h:panelGrid  >

                <h:selectOneMenu id="option" value = "#{mealManagerBean.option}">
                    <f:selectItem itemLabel="Select Meal Type" itemValue="" />  
                    <f:selectItems value="#{mealManagerBean.options}" />
                </h:selectOneMenu>

                <h:outputLabel for="mealName" style="font-weight: bold" value="Meal Name: " />
                <h:inputText required="true" label="Meal Name" requiredMessage="Meal Name is required." id="mealName" value="#{mealManagerBean.selectedMeal.name}">
                </h:inputText>

                <h:outputLabel for="originalPrice" style="font-weight: bold" value="Original Price: " />
                <h:inputText required="true" label="Original Price" requiredMessage="Original Price is required." id="originalPrice" value="#{mealManagerBean.selectedMeal.originalPrice}"/>

                <h:outputLabel for="description" style="font-weight: bold" value="Description: " />
                <h:inputText required="true" label="Description" requiredMessage="Description is required." id="description" value="#{mealManagerBean.selectedMeal.description}"/>

                <h:outputLabel for="videoLink" style="font-weight: bold" value="Video Link: " />
                <h:inputText required="false" label="Video Link" id="videoLink" value="#{mealManagerBean.selectedMeal.videoLink}"/>

                <h:outputText value="Visible to Customers, check for YES: "/>
                <h:selectBooleanCheckbox id="checkbox" value="#{mealManagerBean.selectedMeal.visibility}"
                                         title="click it to select or deselect"/>

                <h:outputText value="Meal image: "/>                         
                <p:fileUpload id="upload" fileUploadListener="#{mealManagerBean.handleImageUpload}" 
                              allowTypes="*.jpg;*.png;*.gif;" description="Images" update ="msg gi"/>     
                <p:growl id="msg" />

            </h:panelGrid>
            <p:commandButton id="btn" value="Save Meal" actionListener="#{mealManagerBean.saveMeal}" ajax="true" update="panel"/>
        </p:panel>
        </h:form>
    </ui:define>
</ui:composition>